<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function (Blueprint $table) {
            $table->id();
            $table->char('mobile',11)->index()->default('')->comment('手机号');
            $table->string('account', 50)->default('')->index()->comment('账号');
            $table->string('nickname',50)->default('')->comment('昵称');
            $table->string('password',255)->default('')->comment('密码');
            $table->string('email',100)->default('')->comment('邮箱');
            $table->tinyInteger('sex')->default(0)->comment('性别:1=男,2=女,0=未知');
            $table->string('avatar',1000)->default('')->comment('头像');
            $table->string('birthday',20)->default('')->comment('生日');
            $table->tinyInteger('status')->default(0)->unsigned()->comment('状态:1=正常,2=禁用');
            $table->tinyInteger('is_delete')->default(0)->unsigned()->comment('是否删除:1=删除,0=正常');
            $table->integer('created_at')->default(0)->comment('创建时间');
            $table->integer('updated_at')->default(0)->comment('修改时间');
            $table->integer('last_login_time')->default(0)->comment('最后登录时间');
        });
        DB::statement("ALTER TABLE `user` comment '【用户】'");
        $list_id = DB::table('admin_menus')->insertGetId([
            'name'        => '用户管理',
            'path'        => 'arts/manage/user',
            'icon'        => 'el-icon-s-custom',
            'module_type' => 'extend',
            'level'       => 2,
            'facility'    => 1,
            'sort'        => 255,
            'status'      => 1,
            'created_at'  => time()
        ]);
        DB::table('admin_menus')->insert([
            [
                'parent_id'   => $list_id,
                'name'        => '钱包',
                'path'        => 'arts/manage/user/wallet',
                'action'      => 'wallet',
                'icon'        => 'el-icon-wallet',
                'level'       => 3,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'parent_id'   => $list_id,
                'name'        => '删除',
                'path'        => 'arts/manage/user/remove',
                'action'      => 'remove',
                'icon'        => 'el-icon-delete',
                'level'       => 3,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ],
            [
                'parent_id'   => $list_id,
                'name'        => '状态',
                'path'        => 'arts/manage/user/status',
                'action'      => 'status',
                'icon'        => 'el-icon-warning',
                'level'       => 3,
                'facility'    => 2,
                'sort'        => 255,
                'status'      => 1,
                'created_at'  => time()
            ]
        ]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user');
    }
};
